package com.aaa.cs.controller;

import com.aaa.common.util.Result;
import com.aaa.cs.entity.Brand;
import com.aaa.cs.service.BrandService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * (Brand)表控制层
 *
 * @author makejava
 * @since 2020-11-18 15:45:31
 */
@RestController
@RequestMapping("brand")
public class BrandController {
    /**
     * 服务对象
     */
    @Resource
    private BrandService brandService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Result selectOne(Long id) {
        return this.brandService.queryById(id);
    }

    @GetMapping("queryAll")
    public Result queryAll(){
        return this.brandService.queryAll();
    }

    /**
     * 分页加各种条件查询
     * @param pageNo
     * @param pageSize
     * @param brand
     * @return
     */
    @GetMapping("queryPageByParam")
    public Result queryPageByParam(Integer pageNo, Integer pageSize, Brand brand){
        return brandService.queryPageByParam(pageNo,pageSize,brand);
    }

    @GetMapping("deleteById")
    public Result deleteById(Long id){
        return brandService.deleteById(id);
    }

    @GetMapping("insertOrUpdate")
    public Result insertOrUpdate(Brand brand){
        return brandService.insertOrUpdate(brand);
    }
}